import QtQuick 2.15
import QtCharts 2.15

ChartView {
    id: chartView
    title: "折线图"
    antialiasing: true
    
    function generateRandomData(count, maxValue) {
        var points = []
        for (var i = 0; i < count; i++) {
            points.push({x: i * 20, y: Math.random() * maxValue})
        }
        return points
    }
    
    Component.onCompleted: {
        var pointList = generateRandomData(5, 101)
        for (var i = 0; i < pointList.length; i++) {
            lineSeries.append(pointList[i].x, pointList[i].y)
            scatterSeries.append(pointList[i].x, pointList[i].y)
        }
    }
    
    LineSeries {
        id: lineSeries
        name: "Line"
        axisX: axisX
        axisY: axisY
    }
    
    ScatterSeries {
        id: scatterSeries
        name: "Scatter"
        markerSize: 8
        axisX: axisX
        axisY: axisY
    }
    
    ValueAxis {
        id: axisX
        min: 0
        max: 100
    }
    
    ValueAxis {
        id: axisY
        min: 0
        max: 100
    }
}

